import secrets
import binascii

# 生成随机的128位密钥
key = secrets.token_bytes(16)

# 生成随机的16字节初始向量
iv = secrets.token_bytes(16)

# 将密钥和初始向量转换为C数组格式
key_arr = ", ".join([f"0x{b:02x}" for b in key])
iv_arr = ", ".join([f"0x{b:02x}" for b in iv])

# 打印Python和ESP32使用的密钥和初始向量
print(f"python_key: key = {key}")
print(f"python_iv: iv = {iv}")
print(f"esp_key: unsigned char key[] = {{{key_arr}}};")
print(f"esp_iv: unsigned char iv[] = {{{iv_arr}}};")